<?php

function getSnoopy($url, $boolhost = true) {
    $ua = array(
        'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
        '(compatible; MSIE 7.01; MSN 2.5; AOL 4.0; Windows XP)',
        'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11',
        'Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)',
        'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
        'Mozilla/5.0 (compatible; EasouSpider; +http://www.easou.com/search/spider.html)',
    );
    $uriinfo = parse_url($url);
    $snoopy = new Snoopy;
    if ($boolhost) {
        $snoopy->host = $uriinfo['host'];
    }
    $snoopy->agent = $ua[mt_rand(0, count($ua) - 1)];
    $snoopy->referer = $uriinfo['scheme'] . '://' . $uriinfo['host'] . '/';
    $snoopy->rawheaders["Pragma"] = "no-cache";
    if ($boolhost) {
        $snoopy->rawheaders["Host"] = $uriinfo['host'];
    }
    $snoopy->rawheaders["X_FORWARDED_FOR"] = mt_rand(1, 255) . '.' . mt_rand(1, 255) . '.' . mt_rand(1, 255) . '.' . mt_rand(1, 255);
    return $snoopy;
}

?>